<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="dao.Chatmessage"%>
<%@page import="dao.User"%>
<%@page import="beans.ChatMessagebean"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
ChatMessagebean chatMessagebean = new ChatMessagebean();
String userId = ((User)session.getAttribute("user")).getUserid();
List<Chatmessage> list2 = chatMessagebean.findSource(userId, "1");
List<Integer> idList = new ArrayList<Integer>();
for(Chatmessage mes:list2){
    idList.add(mes.getReplyid());
}
List<Chatmessage> list3 = chatMessagebean.findMessageByids(idList);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>已处理留言</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<style type="text/css">
body {
	font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica,
		sans-serif;
	color: #4f6b72;
	text-align: center;
	background: #E6EAE9;
}

#container {
	margin-left: auto;
	margin-right: auto;
	width: 1000px;
	height: 100%;
	background: #f8f8f8;
	border: 2px solid #777;
	display: block;
	vertical-align: middle;
}

.ele {	
	margin-top: 20px;
	margin-botton: 10px;
	text-align: center;
	width: 100%;
	display: block;
	vertical-align: middle;
}
.reply{
	color: #4f6b72;
	margin-top: 10px;
	margin-botton: 10px;
	text-align: center;
	width: 100%;
	display: block;
	vertical-align: middle;
}
</style>
  </head>
  
  <body>
    <div id="container">
    <h3>已处理留言</h3>
	<div>
	<c:choose>
		<c:when test="<%=list2 !=null && list2.size() >0 %>">
			<%
				DateFormat formater = new SimpleDateFormat("yyyy年MM月dd日 hh:MM:ss");
			    for (Chatmessage message: list2) {
					Chatmessage mes = null;
					for(int j=0;j<list3.size();j++){
					    if(list3.get(j).getMessageid().intValue() == message.getReplyid().intValue()){
							mes = list3.get(j);
					    }
					}
				String time = formater.format(message.getSendtime());
				String time2 = formater.format(mes.getSendtime());
			%>
			<div class="ele">
			<label>发送时间：</label><%=time %><br>
			<label>留言内容：</label><%=message.getMessage() %><br>					
			</div>
			<div class="reply">
			<label>回复：</label><%=mes.getMessage() %><br>
			<label>回复时间：</label><%=time2 %><br> 
			</div>
			<hr>
			<%
			    }
			%>
		</c:when>
		<c:otherwise>			
			<c:out value="没有已处理留言"></c:out>
		</c:otherwise>
		</c:choose>
		</div>
	</div>
  </body>
</html>
